// used to transfer the data over to the RFM12 in byte form
struct position{
	float	lat;
	float	lon;
	float	alt;
};

// the buffer to send out data using the rfm12
union {
    position	pos;
    uint8_t	bytes[12];
} _txbuf;

//the buffer to receive data from the rfm12
union {
    position	pos;
    uint8_t	bytes[12];
} _rxbuf;

uint8_t *bufptr;
uint8_t rxcounter;

volatile uint8_t  osd_got_target;               // tels if got target position or not
volatile float    osd_target_lat;               // target latidude
volatile float    osd_target_lon;               // target longitude
volatile float    osd_target_alt;
volatile long     osd_target_distance;          // distance from home
volatile uint8_t  osd_target_direction;         // Arrow direction pointing to target (1-16 to CW loop)

// used to remember when we received last info from other aircraft
volatile long	  last_target_rx;

volatile bool	  mt3329_active;

enum diyd_mtk_protocol_bytes {
        PREAMBLE1 = 0xd0,
        PREAMBLE2 = 0xdd,
    };
    
struct diyd_mtk_msg {
        int32_t		latitude;
        int32_t		longitude;
        int32_t		altitude;
        int32_t		ground_speed;
        int32_t		ground_course;
        uint8_t		satellites;
        uint8_t		fix_type;
        uint32_t	utc_date;
        uint32_t	utc_time;
        uint16_t	hdop;
};

// Receive buffer
union {
    diyd_mtk_msg	msg;
    uint8_t			bytes[];
} _buffer;

enum diyd_mtk_fix_type {
        FIX_NONE = 1,
        FIX_2D = 2,
        FIX_3D = 3
};

uint8_t ck_a;
uint8_t ck_b;
uint8_t _ck_a;     // Packet checksum
uint8_t _ck_b;
uint8_t _step;
uint8_t _payload_counter;

